import { configureStore } from '@reduxjs/toolkit'
import { countSlice } from '@/store/modules/count'

// 创建store对象
const store = configureStore({
  // 合并所有的reducer
  reducer: {
    count: countSlice.reducer,
  },
})

// 导出store对象
export default store

store.subscribe(() => {
  // 这里可以获取到状态最新的数据
  console.log('subscribe', store.getState().count.count)
  console.log('subscribe', store.getState().count.msg)
})
// store.dispatch(testSlice.actions.add(undefined))
// store.dispatch(testSlice.actions.sub(2))
// console.log('action', testSlice.actions.sub(2))
// store.dispatch({ type: 'xxx/sub', payload: 3 })
